<?php

class FeedbackFace extends FaceBase
{
	private $nohf = ['add', 'doadd'];
	private $mysql = null;

	public function __construct()
	{
		parent::__construct();
		if(!in_array(N_ACTION,$this->nohf)){
			n_mod('skin')->header();
		}
		$this->mysql = n_api('mysql')->cname('weixin');
	}

	public function index()
	{
		$ppid = $_SESSION['ppid'];
		$data = $this->mysql->select("select * from feedback_main where ppid = $ppid");
		$this->_html('index', $data);
	}

	public function add()
	{
		$this->_html('add');
	}

	public function doAdd()
	{
		$param = $this->param('title:char:empty,desc:char:empty');
		$ppid = $_SESSION['ppid'];

		$data = [
			'title' => $param['title'],
			'desc' => $param['desc'],
			'ppid' => $ppid,
			'ctime' => time()
		];

		$this->mysql->insert('feedback_main', $data);
		echo 'ok';		
	}

	public function __destruct(){
		//加入标准尾。
		if(!in_array(N_ACTION,$this->nohf) && 'page'==N_TYPE){
			n_mod('skin')->footer();
		}
	}

}